import 'package:json_annotation/json_annotation.dart';
import 'package:yt_devops/model/task_tail_model.dart';
import 'package:yt_devops/utils/enums.dart';

import 'device_model.dart';

class TaskDetailModel<S> {
  String? address;
  String? closeTime;
  String? content;
  int? createBy;
  String? createName;
  String? createTime;
  int? current;
  String? description;
  String? email;
  String? endTime;
  int? handlerBy;
  String? handlerName;

  ///任务单号，示例：85
  int? id;
  String? name;
  int? objId;
  int? orgId;
  String? orgName;
  int? pageSize;
  String? phone;
  String? processTime;
  String? remark;
  dynamic service;
  String? site;
  int? siteId;
  int? sourceId;
  String? startTime;
  int? taskTailId;
  String? timeOfAppointment;

  ///install(0, "安装工单"),
  TaskType? type;
  dynamic updateBy;
  dynamic updateName;
  dynamic updateTime;
  int? userId;
  String? userName;
  S? status; //状态
  List<TaskTailModel>? tails; //进度
  String? descPicUrl;
  String? processingResults;
  double? longitude;
  double? latitude;
  TaskDetailModel(
      {this.address,
      this.closeTime,
      this.content,
      this.createBy,
      this.createName,
      this.createTime,
      this.current,
      this.description,
      this.email,
      this.endTime,
      this.handlerBy,
      this.handlerName,
      this.id,
      this.name,
      this.objId,
      this.orgId,
      this.orgName,
      this.pageSize,
      this.phone,
      this.processTime,
      this.remark,
      this.service,
      this.site,
      this.siteId,
      this.sourceId,
      this.startTime,
      this.tails,
      this.taskTailId,
      this.timeOfAppointment,
      this.type,
      this.updateBy,
      this.updateName,
      this.updateTime,
      this.userId,
      this.userName,
      this.descPicUrl,
      this.processingResults,
      this.latitude,
      this.longitude,
      DeviceModel? deviceInfo});

  factory TaskDetailModel.fromJson(Map<String, dynamic> json) =>
      TaskDetailModel(
        id: json['id'],
        name: json['name'],
        address: json['address'],
        content: json['content'],
        handlerBy: json['handlerBy'],
        orgId: json['orgId'],
        phone: json['phone'],
        timeOfAppointment: json['timeOfAppointment'],
        userId: json['userId'],
        orgName: json['orgName'],
        handlerName: json['handlerName'],
        userName: json['userName'],
        createName: json['createName'],
        descPicUrl: json['descPicUrl'],
        processingResults: json['processingResults'],
        deviceInfo: json['deviceInfo'] == null
            ? null
            : DeviceModel.fromJson(json['deviceInfo']),
        tails: List.of(
              json['tails'],
            ).map((e) => TaskTailModel.fromJson(e)).toList() ??
            [],
        type: $enumDecodeNullable($TaskTypeEnumMap, json['type']),
      );
}
